<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Contract\ValidatorInterface;
use Hyperf\Utils\Context;
use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\ValidationException;
use Psr\Http\Message\ResponseInterface;

class Request extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }
//
//    public function failedValidation(ValidatorInterface $validator)
//    {
//        $messageList = [];
//        foreach ($validator->errors() as $items) {
//            foreach ($items as $item) {
//                $messageList[] = $item;
//            }
//        }
//        $message = implode('<br>', $messageList);
//        $format = json_encode(['message' => $message]);
//
//
//        $response = Context::get(ResponseInterface::class);
//        $response->withStatus(200);
//
//        throw (new ValidationException($validator,$response))->errorBag($this->errorBag);
//    }
}
